package com.tongda.core.service;


import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;

import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;

import android.util.Log;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tongda.core.common.Constants;
import com.tongda.core.enums.StatusCodeEnum;
import com.tongda.core.utils.CommunicationUtil;
import com.tongda.core.utils.Page;
import com.tongda.core.vo.Bill;
import com.tongda.core.vo.CancelBillReason;
import com.tongda.core.vo.CancelDishReason;
import com.tongda.core.vo.CashDiscount;
import com.tongda.core.vo.Dish;
import com.tongda.core.vo.DishesAvoidfood;
import com.tongda.core.vo.DishesSetDishesReplace;
import com.tongda.core.vo.DishesTaste;
import com.tongda.core.vo.DwzAjaxDone;
import com.tongda.core.vo.MobileRspResult;

public class BillService extends BaseService {

	/**
	 * 取帐单列表数据
	 * 
	 * @param uriVariables
	 * @return
	 */
	public static Page<Bill> getBillList(Map<String, ?> uriVariables) {
		ObjectMapper objectMapper = new ObjectMapper();
		String suffix = "?";
		if (uriVariables != null) {
			Set<String> keys = uriVariables.keySet();
			for (String key : keys) {
				Object value = uriVariables.get(key);
				suffix += key + "=" + value + "&";
			}
		}
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/list" + suffix);
		Bill[] arr;
		Page<Bill> page;
		try {
			page = objectMapper.readValue(jsonStr, Page.class);
			arr = objectMapper.readValue(page.getDataStr(), Bill[].class);
			ArrayList<Bill> list = new ArrayList<Bill>();
			for (Bill bill : arr) {
				list.add(bill);
			}
			page.setDataList(list);
			return page;
		} catch (JsonParseException e) {
			e.printStackTrace();
		} catch (JsonMappingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 取帐单列表数据
	 * 
	 * @param uriVariables
	 * @return
	 */
	public static Page<Bill> searchbill(Map<String, ?> uriVariables) {
		ObjectMapper objectMapper = new ObjectMapper();
		/*
		 * ResponseEntity<Bill[]>
		 * responseEntity=BaseService.get("mobile/bill/list", Bill[].class,
		 * uriVariables); if(responseEntity!=null){ return
		 * Arrays.asList(responseEntity.getBody()); }
		 */
		String suffix = "?";
		if (uriVariables != null) {
			Set<String> keys = uriVariables.keySet();
			for (String key : keys) {
				Object value = uriVariables.get(key);
				suffix += key + "=" + value + "&";
			}
		}
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/searchbill" + suffix);
		Bill[] arr;
		Page<Bill> page;
		try {
			// objectMapper.set
			page = objectMapper.readValue(jsonStr, Page.class);
			arr = objectMapper.readValue(page.getDataStr(), Bill[].class);
			ArrayList<Bill> list = new ArrayList<Bill>();
			for (Bill bill : arr) {
				list.add(bill);
			}
			page.setDataList(list);
			return page;
		} catch (JsonParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JsonMappingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	
	/**
	 * 取帐单明细数据
	 * 
	 * @param uriVariables
	 * @return
	 */
	public static Bill getBillDetail(Map<String, ?> uriVariables, boolean isxiadan) {
		ObjectMapper objectMapper = new ObjectMapper();
		String suffix = "?";
		if (uriVariables != null) {
			Set<String> keys = uriVariables.keySet();
			for (String key : keys) {
				Object value = uriVariables.get(key);
				suffix += key + "=" + value + "&";
			}
		}
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/detail" + suffix);
		Bill bill = null;
		Dish[] arr;
		try {
			bill = objectMapper.readValue(jsonStr, Bill.class);
			if (bill.getDishesStr() != null && bill.getDishesStr() != "") {
				arr = objectMapper.readValue(bill.getDishesStr(), Dish[].class);
				ArrayList<Dish> list = new ArrayList<Dish>();
				for (Dish dish : arr) {
					if (isxiadan) {
						if (!dish.getDishesStatus().equals("3") && !dish.getDishesStatus().equals("4")) {
							list.add(dish);
						}
					} else {
						list.add(dish);
					}
				}
				bill.setDishes(list);
			}
			return bill;
		} catch (JsonParseException e) {
			e.printStackTrace();
		} catch (JsonMappingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return bill;
	}
	
	public static Map<String,String> getBillCostAndDishesCount(String billId) {
		ResponseEntity<MobileRspResult> responseEntity = BaseService.postUrl("mobile/bill/getBillCostAndDishesCount?id="+billId, MobileRspResult.class);
		if (responseEntity != null) {
			MobileRspResult r = responseEntity.getBody();
			return parseObjectToT(r.getObject(), Map.class); 
		}
		Map<String,String> map = new HashMap<String,String>();
		map.put( "totalDishesCount","0");
		map.put( "oriCost","0");
		return map;
	}

	/**
	 * 取消修改操作
	 * 
	 * @param billId
	 */
	public static void quXiaoXG(String billId) {
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/quxiaoxg" + "?billId=" + billId);
	}

	/**
	 * 删菜操作
	 * 
	 * @param billId
	 */
	public static void shancai(String billId, String dishId,String isSet) {
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/deletedish" + "?dishId=" + dishId + "&billId=" + billId+"&isSet=" + isSet);
	}

	/**
	 * 催菜操作
	 * 
	 * @param billId
	 */
	public static void urgedish(String dishId,String isSet) {
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/urgedish" + "?dishId=" + dishId + "&time=" + Long.toString((new Date()).getTime())+"&isSet="+isSet);
	}

	/**
	 * 整单催菜操作
	 * 
	 * @param billId
	 */
	public static void urgebill(String billId) {
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/urgebill" + "?billId=" + billId + "&time=" + Long.toString((new Date()).getTime()));
	}

	/**
	 * 退菜操作
	 * 
	 * @param num
	 * @param billId
	 */
	/**
	 * 退菜操作
	 * 
	 * @param num
	 * @param billId
	 */
	public static void cancelDish(String dishId, String cancelReasonId, String num,boolean backornot,String isSet,String newAddReason) {
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/canceldish" + "?dishId=" + dishId + "&cancelReasonId=" + cancelReasonId + "&cancelNum=" + num+"&backornot="+backornot+"&isSet="+isSet+"&newAddReason="+newAddReason);
	}

	/**
	 * 划菜
	 * 
	 * @param dishId
	 */
	public static void huacai(String dishId,String isSet) {
		// TODO Auto-generated method stub
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/huacai" + "?dishId=" + dishId+"&isSet=" + isSet);
	}

	/**
	 * 获取退菜原因
	 */
	public static List<CancelDishReason> getTuiCaiYuanYin() {
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/gettuicaiyuanyin");
		if (jsonStr != null && jsonStr != "") {
			ObjectMapper objectMapper = new ObjectMapper();
			try {
				CancelDishReason[] arr = objectMapper.readValue(jsonStr, CancelDishReason[].class);
				if (arr.length > 0) {
					ArrayList<CancelDishReason> list = new ArrayList<CancelDishReason>();
					for (CancelDishReason cdr : arr) {
						list.add(cdr);
					}
					return list;
				}
			} catch (JsonParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (JsonMappingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 获取撤单原因
	 */
	public static List<CancelBillReason> getCheDanYuanYin() {
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/getchedanyuanyin");
		if (jsonStr != null && jsonStr != "") {
			ObjectMapper objectMapper = new ObjectMapper();
			try {
				CancelBillReason[] arr = objectMapper.readValue(jsonStr, CancelBillReason[].class);
				if (arr.length > 0) {
					ArrayList<CancelBillReason> list = new ArrayList<CancelBillReason>();
					for (CancelBillReason cdr : arr) {
						list.add(cdr);
					}
					return list;
				}
			} catch (JsonParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (JsonMappingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 下单
	 * 
	 * @param billId
	 */
	public static String xiadan(String billId) {
		// TODO Auto-generated method stub
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/xiadan" + "?billId=" + billId);
		return jsonStr;
	}

	/**
	 * 快速点餐 加菜
	 * 
	 * @param dishId
	 * @param unitNum
	 */
	public static MobileRspResult updateDish(String billId, String dishId, String unitNum,String isJudgeRm) {
		
		ResponseEntity<MobileRspResult> responseEntity = BaseService.postUrl("mobile/bill/updatejiacai" + "?billId=" + billId + "&dishId=" + dishId + "&unitNum=" + unitNum+"&isJudgeRm="+isJudgeRm, MobileRspResult.class);
		if (responseEntity != null) {
			MobileRspResult r = responseEntity.getBody();
			if(r.getStatusCode().equals(StatusCodeEnum.SUCCESS.getCode()))
			{
				Map<String,String> map = parseObjectToT(r.getObject(), HashMap.class);
				r.setMap(map);
				return r;
			}
			else
			{
				return responseEntity.getBody();
			}
		}
		return new MobileRspResult(StatusCodeEnum.ERROR.getCode(),"失败","");
	}
	
	/**
	 * 快速点餐 加菜 （套餐）
	 * 
	 * @param dishId
	 * @param unitNum
	 */
	public static MobileRspResult updateDishSet(String billId, String dishId, String unitNum,String isJudgeRm) {
		ResponseEntity<MobileRspResult> responseEntity = BaseService.postUrl("mobile/bill/updatedishSetjiacai" + "?billId=" + billId + "&dishId=" + dishId + "&unitNum=" + unitNum+"&isJudgeRm="+isJudgeRm, MobileRspResult.class);
		if (responseEntity != null) {
			MobileRspResult r = responseEntity.getBody();
			if(r.getStatusCode().equals(StatusCodeEnum.SUCCESS.getCode()))
			{
				Map<String,String> map = parseObjectToT(r.getObject(), HashMap.class);
				r.setMap(map);
				return r;
			}
			else
			{
				return responseEntity.getBody();
			}
		}
		return new MobileRspResult(StatusCodeEnum.ERROR.getCode(),"失败","");
	}

	/**
	 * 撤单
	 * 
	 * @param billId
	 * @param reasonsId
	 */
	public static void chedan(String billId, String reasonsId) {
		// TODO Auto-generated method stub
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/chedan" + "?billId=" + billId + "&reaId=" + reasonsId);
	}

	/**
	 * 取所有 口味
	 * 
	 * @return
	 */
	public static List<DishesTaste> getAllDishesTaste() {
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/getkouwei");
		if (jsonStr != null && jsonStr != "") {
			ObjectMapper objectMapper = new ObjectMapper();
			try {
				DishesTaste[] arr = objectMapper.readValue(jsonStr, DishesTaste[].class);
				if (arr.length > 0) {
					Log.d("", String.valueOf(arr.length));
					return Arrays.asList(arr);
				} else {
					return null;
				}
			} catch (JsonParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (JsonMappingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return new ArrayList<DishesTaste>();
	}

	/**
	 * 取所有忌口
	 * 
	 * @return
	 */
	public static List<DishesAvoidfood> getAllDishesAvoidfoods() {
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/getjikou");
		if (jsonStr != null && jsonStr != "") {
			ObjectMapper objectMapper = new ObjectMapper();
			try {
				DishesAvoidfood[] arr = objectMapper.readValue(jsonStr, DishesAvoidfood[].class);
				if (arr.length > 0) {
					return Arrays.asList(arr);
				}
			} catch (JsonParseException e) {
				e.printStackTrace();
			} catch (JsonMappingException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return new ArrayList<DishesAvoidfood>();
	}

	public static String savePrbz(String type, String id, String dishesTastesIdArr, String dishesTastesNameArr, String dishesAvoidfoodIdArr, String dishesAvoidfoodNameArr, int ladu_value, String beizhu,String isSet) {
		Map map = new HashMap<String, String>();
		map.put("type", type);
		map.put("id", id);
		map.put("dishesTastesIdArr", dishesTastesIdArr);
		map.put("dishesTastesNameArr", dishesTastesNameArr);
		map.put("dishesAvoidfoodIdArr", dishesAvoidfoodIdArr);
		map.put("dishesAvoidfoodNameArr", dishesAvoidfoodNameArr);
		map.put("ladu", String.valueOf(ladu_value));
		map.put("beizhu", beizhu);
		map.put("isSet", isSet);
		String result = CommunicationUtil.post(Constants.BASE_SERVIER_URL + "mobile/bill/savePrbz", map);
		return "success";
	}

	/**
	 * 根据id或者账单菜肴信息
	 * 
	 * @param id
	 * @return
	 * @throws JsonParseException
	 * @throws JsonMappingException
	 * @throws IOException
	 */
	public static Dish getDishById(String id,String isSet)  {
		Dish dish = null;
		try
		{
			String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/getDishById?id=" + id+"&isSet="+isSet);
			ObjectMapper objectMapper = new ObjectMapper();
			dish = objectMapper.readValue(jsonStr, Dish.class);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return dish;
	}

	/**
	 * 取帐单明细数据
	 * 
	 * @param uriVariables
	 * @return
	 */
	public static Bill showDetail(Map<String, ?> uriVariables, boolean isxiadan) {
		ObjectMapper objectMapper = new ObjectMapper();
		/*
		 * ResponseEntity<Bill[]>
		 * responseEntity=BaseService.get("mobile/bill/list", Bill[].class,
		 * uriVariables); if(responseEntity!=null){ return
		 * Arrays.asList(responseEntity.getBody()); }
		 */
		String suffix = "?";
		if (uriVariables != null) {
			Set<String> keys = uriVariables.keySet();
			for (String key : keys) {
				Object value = uriVariables.get(key);
				suffix += key + "=" + value + "&";
			}
		}
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/showdetail" + suffix);
		Bill bill = null;
		Dish[] arr;
		try {
			bill = objectMapper.readValue(jsonStr, Bill.class);
			if (bill.getDishesStr() != null && bill.getDishesStr() != "") {
				arr = objectMapper.readValue(bill.getDishesStr(), Dish[].class);
				ArrayList<Dish> list = new ArrayList<Dish>();
				for (Dish dish : arr) {
					if (isxiadan) {
						if (!dish.getDishesStatus().equals("3") && !dish.getDishesStatus().equals("4")) {
							list.add(dish);
						}
					} else {
						list.add(dish);
					}
				}
				bill.setDishes(list);
			}
			return bill;
		} catch (JsonParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JsonMappingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return bill;
	}

	/**
	 * 现金支付
	 * 
	 * @return
	 */
	public static DwzAjaxDone saveMoneyPayment(String billId, String money) {
		Map<String, Object> params = new WeakHashMap<String, Object>();
		params.put("money", money);
		ResponseEntity<DwzAjaxDone> responseEntity = BaseService.get("/mobile/bill/saveMoneyPayment/" + billId, DwzAjaxDone.class, params);
		if (responseEntity != null) {
			return responseEntity.getBody();
		}
		return null;
	}

	/**
	 * 根据不同的支付方式更新支付方式数据 eg：优惠券 ，会员卡 ，支票 。。。
	 * 
	 * @param billId账单ID
	 * @param cptId
	 *            付款方式ID
	 * @param money
	 *            付款金额
	 * @param dbpId
	 *            付款ID（修改付款金额）
	 * @param mcId
	 *            会员卡ID
	 * @return
	 */
	public static DwzAjaxDone savePaymentByType(String billId, String cptId, String dbpId, String mcId, String mbId, String money, String paymentType,String membercardPayType) {
		Map<Object, Object> params = new WeakHashMap<Object, Object>();
		params.put("billId", billId);
		params.put("cptId", cptId);
		params.put("dbpId", dbpId);
		params.put("mcId", mcId);
		params.put("mbId", mbId);
		params.put("money", money);
		params.put("paymentType", paymentType);
		params.put("membercardPayType", membercardPayType);
		
	    CommunicationUtil.post(Constants.BASE_SERVIER_URL+"/mobile/bill/pop/paymentType/update", params);
		return null;
	}

	
	/**
	 * 获取折扣方案
	 * @param billId账单ID
	 * @param restaurantId餐馆ID
	 * @param page页数
	 * @return
	 */
	
	public static Page<CashDiscount> getCashDiscount(Map<String, ?> uriVariables) {
		ObjectMapper objectMapper = new ObjectMapper();
		/*
		 * ResponseEntity<Bill[]>
		 * responseEntity=BaseService.get("mobile/bill/list", Bill[].class,
		 * uriVariables); if(responseEntity!=null){ return
		 * Arrays.asList(responseEntity.getBody()); }
		 */
		String suffix = "?";
		if (uriVariables != null) {
			Set<String> keys = uriVariables.keySet();
			for (String key : keys) {
				Object value = uriVariables.get(key);
				suffix += key + "=" + value + "&";
			}
		}
		String jsonStr = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/getCashDiscount" + suffix);
		CashDiscount[] arr;
		Page<CashDiscount> page;
		try {
			page = objectMapper.readValue(jsonStr, Page.class);
			arr = objectMapper.readValue(page.getDataStr(), CashDiscount[].class);
			ArrayList<CashDiscount> list = new ArrayList<CashDiscount>();
			for (CashDiscount bill : arr) {
				list.add(bill);
			}
			// page.setDataList(Arrays.asList(arr));
			page.setDataList(list);
			return page;
			
		} catch (JsonParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JsonMappingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	

	/**
	 * 结账
	 * 
	 * @return
	 */
	public static DwzAjaxDone pay(String billId, String isPrint, String isForce) {
		Map<String, Object> params = new WeakHashMap<String, Object>();
		params.put("billId", billId);
		params.put("isPrint", isPrint);
		params.put("isForce", isForce);
		ResponseEntity<DwzAjaxDone> responseEntity = BaseService.get("/mobile/bill/pay", DwzAjaxDone.class, params);
		if (responseEntity != null) {
			return responseEntity.getBody();
		}
		return null;
	}

	/**
	 * 保存折扣方案
	 * 
	 * @return
	 */
	public static DwzAjaxDone saveCashDiscount(String ccdId, String billId) {
		Map<String, Object> params = new WeakHashMap<String, Object>();
		params.put("billId", billId);
		ResponseEntity<DwzAjaxDone> responseEntity = BaseService.get("mobile/bill/cashDiscount/"+ccdId, DwzAjaxDone.class, params);
		if (responseEntity != null) {
			return responseEntity.getBody();
		}
		return null;
	}
	
	/**
	 * 取消折扣方案
	 * 
	 * @return
	 */
	public static DwzAjaxDone cancleCashDiscount(String ccdId, String billId) {
		Map<String, Object> params = new WeakHashMap<String, Object>();
		params.put("billId", billId);
		ResponseEntity<DwzAjaxDone> responseEntity = BaseService.get("/mobile/bill/cancleCashDiscount/"+ccdId, DwzAjaxDone.class, params);
		if (responseEntity != null) {
			return responseEntity.getBody();
		}
		return null;
	}
	
	/**
	 * 保存备注信息
	 * 
	 * @return
	 */
	public static DwzAjaxDone saveNotes(String id, String notes) {
		Map<String, Object> params = new WeakHashMap<String, Object>();
		params.put("notes", notes);
		ResponseEntity<DwzAjaxDone> responseEntity = BaseService.get("mobile/bill/notes/"+id, DwzAjaxDone.class, params);
		if (responseEntity != null) {
			return responseEntity.getBody();
		}
		return null;
	}
	
	/**
	 * 预结
	 * 
	 * @return
	 */
	public static DwzAjaxDone predict(String id) {
		ResponseEntity<DwzAjaxDone> responseEntity = BaseService.get("mobile/bill/predict/"+id, DwzAjaxDone.class, null);
		if (responseEntity != null) {
			return responseEntity.getBody();
		}
		return null;
	}
	
	public static HttpEntity<Boolean> changeTableOrderStatus(Object obj) {
		return BaseService.postEntity("mobile/bill/changeTableOrderStatus", obj.getClass(), obj, Boolean.class);
	}
	
	
	/**
	 * 获取套餐内该有的菜品
	 * 
	 * @return
	 */
	public static ArrayList<Dish> findByRestIdAndDishesSet(String dsId){
		Map<String, Object> uriVariables = new WeakHashMap<String, Object>();
		uriVariables.put("dsId", dsId);
		List<Dish> categoryList = null;
		ArrayList<Dish> datas = new ArrayList<Dish>();
		ResponseEntity<Dish[]> responseEntity = BaseService.get("mobile/bill/findByRestIdAndDishesSet", Dish[].class, uriVariables);
		if (responseEntity != null) {
			categoryList=Arrays.asList(responseEntity.getBody());
			datas.addAll(categoryList);
		}
		return datas;
		
	}
	
	/**
	 * 获取套餐内该有的菜品的替换菜品信息
	 * 
	 * @return
	 */
	public static   ArrayList<Dish> getReplaceDishes(String dsId, String dsDishesId){
		Map<String, Object> uriVariables = new WeakHashMap<String, Object>();
		uriVariables.put("dsId", dsId);
		uriVariables.put("dsDishesId", dsDishesId);
		List<Dish> categoryList = null;
		ArrayList<Dish> datas = new ArrayList<Dish>();
		ResponseEntity<Dish[]> responseEntity = BaseService.get("/mobile/bill/replaceDishesContent", Dish[].class, uriVariables);
		if (responseEntity != null) {
			categoryList=Arrays.asList(responseEntity.getBody());
			datas.addAll(categoryList);
		}
		return datas;
	}
	
	
	
	/**
	 * 点餐中套餐替换后更新
	 * 
	 * @return
	*/
	 
	public static void editDishesSetReplace(String dishesId, String dsDishesDesc) {
		Map<Object, Object> params = new WeakHashMap<Object,Object>();
		params.put("dishesId", dishesId);
		params.put("dsDishesDesc", dsDishesDesc);
		CommunicationUtil.post(Constants.BASE_SERVIER_URL +"mobile/bill/editDishesSetReplace", params);
	}
	
	/**
	 * 获取套餐内该有的菜品的替换菜品信息
	 * 
	 * @return
	 */
	public static   List<DishesSetDishesReplace> getMenuReplaceDishes(String dsId, String dsDishesId){
		Map<String, Object> uriVariables = new WeakHashMap<String, Object>();
		uriVariables.put("dsId", dsId);
		uriVariables.put("dsDishesId", dsDishesId);
		List<DishesSetDishesReplace> datas = new ArrayList<DishesSetDishesReplace>();
		ResponseEntity<DishesSetDishesReplace[]> responseEntity = BaseService.get("/mobile/bill/replaceDishesContent", DishesSetDishesReplace[].class, uriVariables);
		if (responseEntity != null) {
			datas=Arrays.asList(responseEntity.getBody());
		}
		return datas;
	}
	
	/**
	 * 获取账单的状态
	 */
	public static String getBillStatus(String billId){
		String billStatus = "";
		billStatus = CommunicationUtil.get(Constants.BASE_SERVIER_URL + "mobile/bill/getBillStatus"+"?billId=" + billId);
		return billStatus;
	}
}
